/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "risk_item")
@NamedQueries({
    @NamedQuery(name = "RiskItem.findAll", query = "SELECT r FROM RiskItem r"),
    @NamedQuery(name = "RiskItem.findByRiId", query = "SELECT r FROM RiskItem r WHERE r.riId = :riId"),
    @NamedQuery(name = "RiskItem.findByRiScope", query = "SELECT r FROM RiskItem r WHERE r.riScope = :riScope"),
    @NamedQuery(name = "RiskItem.findByRiDescrip", query = "SELECT r FROM RiskItem r WHERE r.riDescrip = :riDescrip"),
    @NamedQuery(name = "RiskItem.findByRiName", query = "SELECT r FROM RiskItem r WHERE r.riName = :riName")})
public class RiskItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ri_id")
    private Integer riId;
    @Basic(optional = false)
    @Column(name = "ri_scope")
    private int riScope;
    @Column(name = "ri_descrip")
    private String riDescrip;
    @Basic(optional = false)
    @Column(name = "ri_name")
    private String riName;
    @JoinColumn(name = "rc_id", referencedColumnName = "rc_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private RiskCategory riskCategory;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "riskItem", fetch = FetchType.LAZY)
    private List<RiskAssessment> riskAssessmentList;

    public RiskItem() {
    }

    public RiskItem(Integer riId) {
        this.riId = riId;
    }

    public RiskItem(Integer riId, int riScope, String riName) {
        this.riId = riId;
        this.riScope = riScope;
        this.riName = riName;
    }

    public Integer getRiId() {
        return riId;
    }

    public void setRiId(Integer riId) {
        this.riId = riId;
    }

    public int getRiScope() {
        return riScope;
    }

    public void setRiScope(int riScope) {
        this.riScope = riScope;
    }

    public String getRiDescrip() {
        return riDescrip;
    }

    public void setRiDescrip(String riDescrip) {
        this.riDescrip = riDescrip;
    }

    public String getRiName() {
        return riName;
    }

    public void setRiName(String riName) {
        this.riName = riName;
    }

    public RiskCategory getRiskCategory() {
        return riskCategory;
    }

    public void setRiskCategory(RiskCategory riskCategory) {
        this.riskCategory = riskCategory;
    }

    public List<RiskAssessment> getRiskAssessmentList() {
        return riskAssessmentList;
    }

    public void setRiskAssessmentList(List<RiskAssessment> riskAssessmentList) {
        this.riskAssessmentList = riskAssessmentList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (riId != null ? riId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RiskItem)) {
            return false;
        }
        RiskItem other = (RiskItem) object;
        if ((this.riId == null && other.riId != null) || (this.riId != null && !this.riId.equals(other.riId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.RiskItem[riId=" + riId + "]";
    }

}
